# 创建占位符图标的 PowerShell 脚本
# 使用 .NET System.Drawing 创建简单的 PNG 图标

Add-Type -AssemblyName System.Drawing

$tabbarPath = "static\tabbar"
$size = 81

# 定义颜色
$normalColor = [System.Drawing.Color]::FromArgb(136, 136, 136)  # #888888
$activeColor = [System.Drawing.Color]::FromArgb(124, 77, 255)   # #7C4DFF

function Create-Icon {
    param(
        [string]$filename,
        [System.Drawing.Color]$color,
        [string]$shape
    )
    
    $bitmap = New-Object System.Drawing.Bitmap($size, $size)
    $graphics = [System.Drawing.Graphics]::FromImage($bitmap)
    $graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
    
    # 清除背景（透明）
    $graphics.Clear([System.Drawing.Color]::Transparent)
    
    $pen = New-Object System.Drawing.Pen($color, 3)
    $brush = New-Object System.Drawing.SolidBrush($color)
    
    $center = $size / 2
    $radius = $size * 0.35
    
    switch ($shape) {
        "star" {
            # 绘制星星（简化版 - 使用多边形）
            $points = @()
            for ($i = 0; $i -lt 10; $i++) {
                $r = if ($i % 2 -eq 0) { $radius } else { $radius * 0.4 }
                $angle = ($i * [Math]::PI / 5) - ([Math]::PI / 2)
                $x = $center + $r * [Math]::Cos($angle)
                $y = $center + $r * [Math]::Sin($angle)
                $points += New-Object System.Drawing.PointF($x, $y)
            }
            $graphics.FillPolygon($brush, $points)
        }
        "heart" {
            # 绘制爱心（简化版 - 使用圆形和三角形组合）
            $graphics.FillEllipse($brush, $center - $radius * 0.5, $center - $radius * 0.3, $radius, $radius)
            $graphics.FillEllipse($brush, $center - $radius * 0.5 + $radius, $center - $radius * 0.3, $radius, $radius)
            $points = @(
                (New-Object System.Drawing.PointF($center - $radius, $center)),
                (New-Object System.Drawing.PointF($center + $radius, $center)),
                (New-Object System.Drawing.PointF($center, $center + $radius * 1.2))
            )
            $graphics.FillPolygon($brush, $points)
        }
        "clock" {
            # 绘制时钟
            $graphics.DrawEllipse($pen, $center - $radius, $center - $radius, $radius * 2, $radius * 2)
            $graphics.DrawLine($pen, $center, $center, $center, $center - $radius * 0.6)
            $graphics.DrawLine($pen, $center, $center, $center + $radius * 0.5, $center + $radius * 0.3)
        }
        "user" {
            # 绘制用户
            $graphics.FillEllipse($brush, $center - $radius * 0.4, $center - $radius * 0.8, $radius * 0.8, $radius * 0.8)
            $graphics.DrawArc($pen, $center - $radius * 0.7, $center, $radius * 1.4, $radius * 1.4, 180, 180)
        }
    }
    
    $filepath = Join-Path $tabbarPath $filename
    $bitmap.Save($filepath, [System.Drawing.Imaging.ImageFormat]::Png)
    
    $graphics.Dispose()
    $bitmap.Dispose()
    $pen.Dispose()
    $brush.Dispose()
    
    Write-Host "✓ 已创建: $filename" -ForegroundColor Green
}

Write-Host "开始创建 TabBar 图标..." -ForegroundColor Cyan
Write-Host ""

# 创建所有图标
Create-Icon "recommend.png" $normalColor "star"
Create-Icon "recommend-active.png" $activeColor "star"

Create-Icon "favorite.png" $normalColor "heart"
Create-Icon "favorite-active.png" $activeColor "heart"

Create-Icon "history.png" $normalColor "clock"
Create-Icon "history-active.png" $activeColor "clock"

Create-Icon "user.png" $normalColor "user"
Create-Icon "user-active.png" $activeColor "user"

Write-Host ""
Write-Host "✅ 所有图标创建完成！" -ForegroundColor Green
Write-Host "图标保存在: $tabbarPath" -ForegroundColor Yellow
Write-Host ""
Write-Host "下一步：重新编译项目以查看效果" -ForegroundColor Cyan
